package com.infore.water.service;

import com.infore.water.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class UserService {

    @Autowired
    private UserDao userDao;

    public Map<String, Object> queryUserByAccountPassword(String account, String password) {
           return userDao.queryUserByAccountPassword(account,password);
    }

    public int changePassword(String userId, String password, String newPassword) {
       Map<String,Object> userMap = userDao.queryUserByUserId(userId);
        int num = 0;
       if(password.equals(userMap.get("password").toString())){
            num = userDao.changePassword(userId,newPassword);
       }else {
            num = -1;
       }
       return num;
    }
}
